package com.example.demo.common;
//统一返回
import lombok.Data;

@Data
public class Result {
    private Integer code;
    private String msg;
    private Object data;

    public static Result success(Integer code,Object data){
        Result result = new Result();
        result.setCode(code);
        result.setMsg("");
        result.setData(data);
        return result;
    }
    public static Result success(Object data){
        Result result = new Result();
        result.setCode(200);
        result.setMsg("");
        result.setData(data);
        return result;
    }
    public static Result success(Integer code,String msg,Object data) {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(data);
        return result;
    }
    //失败的信息
    public static Result fail(Integer code,String msg){
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }
    public static Result fail(Integer code,String msg,Object data){
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(data);
        return result;
    }
}
